package com.styytech.dadabao.api.requestresult;

import com.styytech.dadabao.api.response.AbstractResponseResult;
import com.styytech.dadabao.bean.ZfbItem;
import com.styytech.dadabao.utils.ParseJsonUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by User on 2015/9/1.
 */
public class ZfbResult extends RequestResult {
    /**
     * 构造函数
     *
     * @param httpResponseResult
     */

    ZfbItem zfbItem = new ZfbItem();

    public ZfbResult(AbstractResponseResult httpResponseResult) {
        super(httpResponseResult);

    }

    @Override
    public void doBusiness() {
        super.doBusiness();
        if (super.isSuccess()) {
            JSONArray jsonArray = (JSONArray) super.getRows();
            dataParse(jsonArray);
        }
    }

    private void dataParse(JSONArray jsonArray) {

        JSONObject jsonObjectApp;

        try {
            if (jsonArray.length() > 0) {
                jsonObjectApp = jsonArray.getJSONObject(0);

                zfbItem = ParseJsonUtils.dataParsezfb(jsonObjectApp);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (httpResponseResult != null) {
            httpResponseResult.executeSuccess(zfbItem);
        }
    }


}


